/*multhread.c*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void *t1_execute(void *arg)
{
    while (1)
    {
        printf("in thread1\n");
    }
}
void *t2_execute(void *arg)
{
    sleep(2);
    pthread_exit(NULL); // 用exit(0);语句替换
}
int main()
{
    pthread_t pid1, pid2;
    int error1, error2;
    error1 = pthread_create(&pid1, NULL, t1_execute, NULL);
    error2 = pthread_create(&pid2, NULL, t2_execute, NULL);
    if (error1 != 0 || error2 != 0)
    {
        printf("pthread_create failed ");
        return -1;
    }
    pthread_join(pid1, NULL);
    pthread_join(pid2, NULL);
    return 0;
}